<?php

declare(strict_types=1);

namespace app\model\admin;

use app\model\AdminBaseModel;
use think\Model;

/**
 * @mixin \think\Model
 * 协议表
 */
class MiniApply extends AdminBaseModel
{
    // 数据表名称
    protected $table = 'mini_apply';
    protected $scopeField = true;

    //可搜索字段
    protected $searchField = [];
    // like
    protected $singleSearchField = [];
    //可作为条件的字段
    protected $whereField = ['status'];  //相等
    protected $append = ['img_url'];
    //可做为时间范围查询的字段
    protected $timeField = ['created_at'];
    public function getImgUrlAttr($val, $data)
    {
        if (isset($data['img'])) {
            return env('APP_URL') . "/" . $data['img'];
        }
    }

    public function user()
    {
        return $this->belongsTo(MiniUser::class, 'user_id', 'id');
    }
}
